package com.hsylient.javase.chapter10;

import org.junit.Test;

import java.time.LocalDate;
import java.util.Calendar;
import java.util.GregorianCalendar;

/**
 * GregorianCalendar在做添加天数或者月数之类的，会改变原对象中的数据
 * LocalDate不会改变是重新生成一个新的指
 */
public class AddDaysTest {

    @Test
    public void testGregorianCalendar() {
        GregorianCalendar gregorianCalendar = new GregorianCalendar(2022, Calendar.DECEMBER, 27);
        gregorianCalendar.add(Calendar.MONTH, 12);
        System.out.println(gregorianCalendar.get(Calendar.MONTH));
    }

    @Test
    public void testLocalDate() {
        LocalDate now = LocalDate.now();
        LocalDate localDate = now.plusWeeks(1);
        System.out.println(localDate);
    }


}
